package com.xzzz.irda.registry.service;

import org.springframework.cloud.client.ServiceInstance;

import java.net.URI;

public class ServiceUtil {

    public static String buildInstanceId(ServiceInstance serviceInstance) {
        return String.format("%s#%s:%s", serviceInstance.getServiceId(), serviceInstance.getHost(), serviceInstance.getPort());
    }

    public static URI buildUri(ServiceInstance serviceInstance) {
        String scheme = "http";
        String uri = String.format("%s://%s:%s", scheme, serviceInstance.getHost(), serviceInstance.getPort());
        return URI.create(uri);
    }
}
